home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Fatted Calf
/
The Fatted Calf.iso
/
Modules
/
BackSpaceModules
/
Source
/
Lizard
/
LizardViewPart.m
< prev
next >
Wrap
Text File
|
1994-05-04
|
2KB
|
96 lines
#import "LizardViewPart.h"
#import "Thinker.h"
#import <appkit/NXImage.h>
#import <appkit/Panel.h> // for NXRunAlertPanel()
#import <dpsclient/wraps.h>
#import <libc.h>
#import <math.h>
@implementation LizardView
- oneStep
{
p=n; n=(n+1)%(NUMLINES-1);
erase=(n-(NUMLINES*.9)); if(erase<0) erase+=(NUMLINES-1);
if(n>(NUMLINES-1))n=0;
t1[n]=t1[p]+0.008; if(t1[n]>(2*PI)) t1[n]-=(2*PI);
t2[n]=t2[p]+0.01; if(t2[n]>(2*PI)) t2[n]-=(2*PI);
t3[n]=t3[p]+0.02; if(t3[n]>(2*PI)) t3[n]-=(2*PI);
t4[n]=t4[p]+0.009; if(t4[n]>(2*PI)) t4[n]-=(2*PI);
t5[n]=t5[p]+0.01; if(t5[n]>(2*PI)) t5[n]-=(2*PI);
t6[n]=t6[p]+0.01; if(t6[n]>(2*PI)) t6[n]-=(2*PI);
t-=0.3; if(t<0)t+=(2*PI);
x1[n]=(cos(t1[n])*(s1))+midx;
yc1[n]=(sin(t2[n])*(s2))+midy;
x2[n]=(cos(t3[n])*(s1))+midx;
y2[n]=(sin(t4[n])*(s2))+midy;
x3[n]=(cos(t5[n])*(s1))+midx;
y3[n]=(sin(t6[n])*(s2))+midy;
PSsetrgbcolor(0.0,0.0,0.0);
PSmoveto(x1[erase], yc1[erase]); PSlineto(x2[erase], y2[erase]);
PSmoveto(x2[erase], y2[erase]); PSlineto(x3[erase], y3[erase]);
PSmoveto(x3[erase], y3[erase]); PSlineto(x1[erase], yc1[erase]);
PSstroke();
if ([self shouldDrawColor])
PSsetrgbcolor((cos(t1[n])+1.0)/2.0,
(cos(t3[n])+1.0)/2.0,
(cos(t5[n])+1.0)/2.0);
else PSsetrgbcolor(1.0, 1.0, 1.0);
PSmoveto(x1[n], yc1[n]); PSlineto(x2[n], y2[n]);
PSmoveto(x2[n], y2[n]); PSlineto(x3[n], y3[n]);
PSmoveto(x3[n], y3[n]); PSlineto(x1[n], yc1[n]);
PSstroke();
return self;
}
- initFrame:(NXRect *)frameRect
{
[super initFrame:frameRect];
[self newSize];
return self;
}
- sizeTo:(NXCoord)width :(NXCoord)height
{
[super sizeTo:width :height];
[self newSize];
return self;
}
- newSize
{
urx=bounds.size.width;
ury=bounds.size.height;
midx=urx/2;
midy=ury/2;
n = 0;
t = 0;
// phases of the three points;
p1=0;
p2=(4*PI)/3;
p3=(2*PI)/3;
// starting angle of each point;
t1[0]=0;
t2[0]=p2;
t3[0]=p3;
s1 = midx; s2 = midy;
return self;
}
@end